<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>游戏管理</title>
    <link rel="stylesheet" href="__ACSS__/table.css">
    <link rel="stylesheet" href="__ACSS__/zeroModal.css">
    <script src="__AJS__/jquery-3.3.1.min.js"></script>
    <script src="__AJS__/common.js"></script>
    <script src="__AJS__/zeroModal.min.js"></script>
</head>
<body>
<div class="table-wrap">
    <div class="table-main">
        <div class="ibox-title">
            <h3>游戏列表</h3>
        </div>
        <div class="ibox-content">
            <form action="index.php" class="form-main" method="get">
                <input type="hidden" name="c" value="user">
                <div class="form-btn">
                    <a href="{:url('admin/game/create')}" target="myIframe">+ 新增游戏</a>
                </div>
                <div class="form-search">
                    <input type="text"  class="form-control"  name="search"  placeholder="以活动名称查找" >
                    <input type="submit" class="search-btn" value="搜索">
                </div>
            </form>
            <table class="list-table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th >游戏名</th>
                    <th >游戏图片</th>
                    <th >游戏描述</th>
                    <th >预览地址</th>
                    <th >所属分类</th>
                    <th >是否开启</th>
                    <th >是否最新</th>
                    <th >是否推荐</th>
                    <th >创建时间</th>
                    <th >操作</th>
                </tr>
                </thead>
                <tbody>

                {volist name="res" id="v"}
                <tr>
                    <td>{$v.id}</td>
                    <td>{$v.gName}</td>
                    <td><img src="/uploads/gameimg/{$v.gImg}"></td>
                    <td>{$v.gDesc}</td>
                    <td>{$v.viewUrl}</td>
                    <td>{$v.cateName}</td>
                   <td>
                        {switch $v.gStatus}
                        {case 1}<a href="" class="btn-icon"><img src="__AIMG__/jump_err.png" alt=""></a>{/case}
                        {case 0}<a href="" class="btn-icon"><img src="__AIMG__/jump_success.png" alt=""></a>{/case}
                        {default /}default
                        {/switch}
                    </td>

                    <td>
                        {switch $v.isNew}
                        {case 1}<a href="" class="btn-icon"><img src="__AIMG__/jump_err.png" alt=""></a>{/case}
                        {case 0}<a href="" class="btn-icon"><img src="__AIMG__/jump_success.png" alt=""></a>{/case}
                        {default /}default
                        {/switch}
                    </td>
                    <td>
                        {switch $v.isRecom}
                        {case 1}<a href="" class="btn-icon"><img src="__AIMG__/jump_err.png" alt=""></a>{/case}
                        {case 0}<a href="" class="btn-icon"><img src="__AIMG__/jump_success.png" alt=""></a>{/case}
                        {default /}default
                        {/switch}
                    </td>
                    <td>{$v.ctime}</td>
                    <td>
                        <div class="btn-group">
                            
                            <a href="{:url('admin/game/edit', ['id' => $v.id ])}" class="btn-white">编辑</a>
                            <a href="javaScript:void(0)" data-id="{$v.id}" class="btn-white delete-btn">删除</a>
                            
                            
                            
                        </div>
                    </td>
                </tr>

                {/volist}

                </tbody>
            </table>
            <div class="btn-limit-group">
                <div class="btn">
                    <a href=""> << </a>
                    <a href=""> 1 </a>
                    <a href=""> 2 </a>
                    <a href=""> 3 </a>
                    <a href=""> 33 </a>
                    <a href=""> 333 </a>
                    <a href=""> 3333 </a>
                    <a href=""> >> </a>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    $(function () {
        // 触发提交删除用户
        $('.delete-btn').click(function () {

            var id = $(this).attr('data-id');
            var obj = $(this).parents('tr');

            zeroModal.confirm({
                content: '您确定删除吗？',
                contentDetail: '删除后将无法恢复!',
                okFn: function() {
                    // 执行添加操作
                    delAjax(id, obj);
                }
            });

        });
    });

    // 执行AJAX删除数据
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/admin/game/delete/id/' + id,
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    zeroModal.success(data.info);
                    obj.remove();
                } else {
                    zeroModal.error(data.info);
                }
            },
            error: function (data) {
                alert('AJAX执行失败!');
            }
        });
    }
</script>
</body>
</html>